#pragma once

#include <AVUIPathSegment.h>

namespace AVUI {

class GeometryBuilder;

class LineSegment : public PathSegment
{
public:
    DECLARE_ELEMENT(LineSegment, PathSegment);

    DECLARE_DEPENDENCY_PROPERTY(Point);
    Point get_Point() { return AVUI::UnboxValue<Point>(GetValue(get_PointProperty())); }
    void set_Point(const Point& value) { SetValue(get_PointProperty(), AVUI::BoxValue(value)); } 

    virtual bool IsCurved() { return false; }
    virtual Rect GetBounds(Point* pStartPoint);
    virtual int ClassifyPoint(const Point& pointClassify, Point* pStartPoint);

    static void BuildGeometryStatic(GeometryBuilder* pGeometryBuilder, const Point& startPoint, const Point& endPoint);
    static int StaticClassifyPoint(const Point& ptClassify, const Point& ptLineStart, const Point& ptLineEnd);
    static int CalculateDistance(const Point& ptClassify, const Point& ptLineStart, const Point& ptLineEnd);

    static bool IsInThickenedLineSegment(const Point& ptClassify, const Point& ptLineStart, const Point& ptLineEnd, float strokeThickness);

protected:
    virtual TRefCountedPtr<Freezable> CreateInstanceCore() AVUI_OVERRIDE { return object_allocate<LineSegment>().get_Ptr(); }

private:
    static void StaticConstructor();

    virtual Point BuildGeometry(GeometryBuilder* pGB, const Point& startPoint);
};



}; // namespace AVUI
